<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="http://at.alicdn.com/t/font_1786038_m62pqneyrzf.css">
    <title>登录</title>

</head>

<link rel="stylesheet" href="/css/login.scc.css">
<script src="./js/jq.js"></script>
<body>
<script>
    function decide() {
        var user;
        var user = $("#username").val();
        $.ajax({
            type:"POST",
            url:"/getDecide",
            data: {user:user},
            success:function (data) {
                if (data == 0){
                    $("#a").html("<font  size='5' color ='red'>☹</font> ")

                }if (data==1){
                    $("#a").html("<font size='5' color='blue'>☺</font>")
                }
            }
        });
    }
    function check(form) {
        alert(form.account);
        alert(form.password)
    }
</script>
<div class="form-wrapper">
    <div class="header">
        SCM
    </div>
    <form >
        <div class="input-wrapper">

            <div class="border-wrapper">
                <input type="text" name="username" id="username" placeholder="username" class="border-item" autocomplete="off" onchange="decide()" + ><span id="a" style="color: blue" >●</span>
            </div>
            <div class="border-wrapper">
                <input type="password" name="password" id="password" placeholder="password" class="border-item" autocomplete="off">
            </div><span   style="color: red ; font-size: 1px" id="error"></span>
        </div>
        <div class="action">
            <input type="button" class="btn" value="login"  onsubmit="return check(this)" onclick= "login() ">
        </div>
    </form>

</div>
<script>
    function login() {
        $.post("login",{
            account:$("#username").val(),
            password:$("#password").val()
        },function (result) {
            if (result.code ==200){
                var account = result.data;
                document.location.href="index.html?account="+account;
            } else {
                 var message=result.message
                document.getElementById("error").innerText=message;
            }
        })
    }
</script>
</body>

</html>